package com.zhujy.huawei;

import java.util.Scanner;

public class Coke {
	
	public static void toCaculate(int num) {
		int res = 0;
		while(num>=3) {
			res += num/3;
			num = num/3 + num%3;
		}
		if(num==2) {
			res++;
		}
		System.out.println(res);
	}
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(in.hasNext()) {
			int num = in.nextInt();
			if(num!=0) {
				toCaculate(num);
			}else {
				System.exit(0);
			}
		}
	}
}
